package com.woniuxy.lab.woniu_lab_boss.docker;


import com.woniuxy.lab.woniu_lab_boss.common.Shell;

public class Image {

    private Shell shell;

    private final static String DOCKER = "docker ";

    public Image() {
    }

    public Image(Shell shell) {
        this.shell = shell;
    }

    public static Image getImage(Shell shell){
        return new Image(shell);
    }

    // -------------


    // 拉取镜像
    public String pull(String imageName){
        return shell.execCommand(DOCKER + "pull "+imageName);
    }

    // 查看所有镜像信息
    public String images(){
        return shell.execCommand(DOCKER + "images");
    }

    // 删除镜像
    public String rmi(String nameOrId){
        return shell.execCommand(DOCKER + nameOrId);
    }

    // 从镜像创建容器
    public String create(String nameOrId){
        return shell.execCommand(DOCKER + "create " + nameOrId);
    }

    // 从文件生成镜像
    public String load(String file) {
        return shell.execCommand(DOCKER + "load < "+ file);
    }

    // 获取包含某镜像名的镜像信息
    public String getImageInfo(String imageName){
        return shell.execCommand(DOCKER + "images | grep " + imageName);
    }

}
